import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/utils/language_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:intl/intl.dart';

mixin MoreButtonMixin {
  final String icon = A.assetsImagesStyleMore_1_2;
}

class NormalMorePopupButton extends StatelessWidget with MoreButtonMixin {
  final ValueChanged<String> onSelect;
  final List<String> menuList;
  final double horizontalPadding;

  NormalMorePopupButton(
      {Key key, this.horizontalPadding, this.onSelect, this.menuList})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PopupMenuButton<String>(
      onSelected: onSelect,
      itemBuilder: _buildMenuItem,
      offset: Offset(0, getDp(19)),
      child: Padding(
        padding: EdgeInsets.symmetric(
            horizontal: horizontalPadding ?? getDp(19), vertical: getDp(10)),
        child: SvgPicture.asset(
          icon,
          width: getDp(21),
          height: getDp(21),
        ),
      ),
    );
  }

  List<PopupMenuEntry<String>> _buildMenuItem(BuildContext context) {
    final style = TextStyle(
      color: aceBlackColor,
      fontSize: getSp(16),
      fontWeight: FontWeight.w700,
      height: 1,
    );
    return menuList
        .map((e) => PopupMenuItem<String>(
              child: Text(LanguageUtils.translateAction(e), style: style),
              value: e,
            ))
        .toList();
  }
}
